package com.itheima.array.array01;
//数组常用算法之：冒泡排序,非常非常重要
public class ArrayDemo3 {
    public static void main(String[] args) {

        int[] arr = {1,13,22,35,41,52,66};
        for (int i = 0; i < arr.length-1; i++) {//外循环控制循环 n-1次
            for (int j = 0; j < arr.length-1-j; j++) {//内循环控制n-1-j次
                if(arr[i] > arr[i+1]){//比数组翻转多了一个判断，前后2个来比较
                   int temp = arr[i];
                   arr[i] = arr[i+1];
                   arr[i+1] = temp;
                }
            }
            System.out.print(arr[i] + " ");
        }

    }
}
